﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using ChatForum.Domain;

namespace ChatForum.DataContract
{
    [DataContract(Name="User")]
    public class UserDTO
    {
        public UserDTO(User user)
        {
			if (user == null)
				throw new ArgumentNullException("user");

            this.FirstName = user.FirstName;
            this.MiddleName = user.MiddleName;
            this.LastName = user.LastName;
            this.UserId = user.UserId;
            this.Sex = user.Sex;
            this.DateOfBirth = user.DateOfBirth;
            this.Country = user.Country;
            this.EmailId = user.EmailId;
            this.AlternateEmailId = user.AlternateEmailId;
            this.Password = user.Password;
            this.Role = DTOEntityMapper.RoleENUMDTO(user.Role);
            this.Status = user.Status;
            this.IsOnline = user.IsOnline;
            this.LastLogInTime = user.LastLogInTime;
            this.MobileNo = user.MobileNo;
            this.ID = user.ID;
            this.CreatedDate = user.CreatedDate;
            this.CreatedBy = user.CreatedBy;
            this.ModifiedDate = user.ModifiedDate;
            this.ModifiedBy = user.ModifiedBy;
        }
        public User Convert()
        {
            return new User()
            {
                FirstName = this.FirstName,
                MiddleName = this.MiddleName,
                LastName = this.LastName,
                UserId = this.UserId,
                Sex = this.Sex,
                DateOfBirth = this.DateOfBirth,
                Country = this.Country,
                EmailId = this.EmailId,
                AlternateEmailId = this.AlternateEmailId,
                Password = this.Password,
                Role = DTOEntityMapper.RoleENUMDTO(this.Role),
                Status = this.Status,
                IsOnline = this.IsOnline,
                LastLogInTime = this.LastLogInTime,
                MobileNo = this.MobileNo,
                ID = this.ID,
                CreatedDate = this.CreatedDate,
                CreatedBy = this.CreatedBy,
                ModifiedDate = this.ModifiedDate,
                ModifiedBy = this.ModifiedBy,
            };
        }

        [DataMember]
        public string FirstName { get; set; }
        [DataMember]
        public string MiddleName { get; set; }
        [DataMember]
        public string LastName { get; set; }
        [DataMember]
        public string UserId { get; set; }
        [DataMember]
        public string Sex { get; set; }
        [DataMember]
        public DateTime DateOfBirth { get; set; }
        [DataMember]
        public string Country { get; set; }
        [DataMember]
        public string EmailId { get; set; }
        [DataMember]
        public string AlternateEmailId { get; set; }
        [DataMember]
        public string Password { get; set; }
        [DataMember]
        public RoleDTOENUM Role { get; set; }
        [DataMember]
        public bool Status { get; set; }
        [DataMember]
        public bool IsOnline { get; set; }
        [DataMember]
        public DateTime LastLogInTime { get; set; }
        [DataMember]
        public string MobileNo { get; set; }


        [DataMember]
        public Guid ID { get; set; }
        [DataMember]
        public DateTime CreatedDate { get; set; }
        [DataMember]
        public string CreatedBy { get; set; }
        [DataMember]
        public DateTime ModifiedDate { get; set; }
        [DataMember]
        public string ModifiedBy { get; set; }
    }
}
